<template>
  <a-modal
    width="600px"
    v-model="modalVisible"
    :bodyStyle="bodyStyle"
    :destroyOnClose="true"
    :maskClosable="false"
    :title="title"
    @cancel="cancel"
  >
    <template slot="footer">
      <a-button key="back" @click="cancel"> 关闭 </a-button>
    </template>
    <a-tabs default-active-key="1" size="small">
      <a-tab-pane key="1" tab="角色">
        <vxe-table
          border
          show-header-overflow
          show-overflow
          highlight-hover-row
          size="small"
          height="300px"
          :data="role"
        >
          <vxe-table-column
            type="seq"
            title="序号"
            width="60"
          ></vxe-table-column>
          <vxe-table-column field="name" title="名称"></vxe-table-column>
          <vxe-table-column
            field="organization"
            title="组织架构"
          ></vxe-table-column> </vxe-table
      ></a-tab-pane>
      <a-tab-pane key="2" tab="人员">
        <vxe-table
          border
          show-header-overflow
          show-overflow
          highlight-hover-row
          size="small"
          height="300px"
          :data="user"
        >
          <vxe-table-column
            type="seq"
            title="序号"
            width="60"
          ></vxe-table-column>
          <vxe-table-column field="name" title="名称"></vxe-table-column>
          <vxe-table-column
            field="organization"
            title="组织架构"
          ></vxe-table-column>
        </vxe-table>
      </a-tab-pane>
      <a-tab-pane key="3" tab="归属机构">
        <vxe-table
          border
          show-header-overflow
          show-overflow
          highlight-hover-row
          size="small"
          height="300px"
          :data="organization"
        >
          <vxe-table-column
            type="seq"
            title="序号"
            width="60"
          ></vxe-table-column>
          <vxe-table-column field="name" title="名称"></vxe-table-column>
          <vxe-table-column
            field="organization"
            title="组织架构"
          ></vxe-table-column>
        </vxe-table>
      </a-tab-pane>
      <a-tab-pane key="4" tab="岗位">
        <vxe-table
          border
          show-header-overflow
          show-overflow
          highlight-hover-row
          size="small"
          height="300px"
          :data="post"
        >
          <vxe-table-column
            type="seq"
            title="序号"
            width="60"
          ></vxe-table-column>
          <vxe-table-column field="name" title="名称"></vxe-table-column>
          <vxe-table-column
            field="organization"
            title="组织架构"
          ></vxe-table-column>
        </vxe-table>
      </a-tab-pane>
      <a-tab-pane key="5" tab="组">
        <vxe-table
          border
          show-header-overflow
          show-overflow
          highlight-hover-row
          size="small"
          height="300px"
          :data="group"
        >
          <vxe-table-column
            type="seq"
            title="序号"
            width="60"
          ></vxe-table-column>
          <vxe-table-column field="name" title="名称"></vxe-table-column>
          <vxe-table-column
            field="organization"
            title="组织架构"
          ></vxe-table-column> </vxe-table
      ></a-tab-pane>
    </a-tabs>
  </a-modal>
</template>

<script>
import { detail } from "@/services/system/permission/detail";
export default {
  name: "detail-permission",
  data() {
    return {
      bodyStyle: {
        padding: "4px",
      },
      role: [],
      group: [],
      post: [],
      user: [],
      organization: [],
      modalVisible: this.visible,
    };
  },

  watch: {
    visible(val) {
      this.modalVisible = val;
    },
  },

  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    title: {
      type: String,
    },
  },

  methods: {
    /**
     * 取消
     */
    cancel() {
      this.$emit("close");
    },

    /**
     * 查找权限信息
     */
    find(id, access) {
      let _this = this;
      detail(id, access).then(function(result) {
        let form = result.data;
        console.log(form);
        _this.role = form.role;
        _this.group = form.group;
        _this.post = form.post;
        _this.user = form.user;
        _this.organization = form.organization;
      });
    },
  },
};
</script>

<style lang="less" scoped>
/deep/ .ant-tabs-bar {
  margin: 0 0 4px 0 !important;
}
</style>
